home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue24 / z_prof / Z_PROF.ZIP / Z_PROF.TXT < prev   
Encoding:
Text File  |  1997-07-03  |  3.9 KB  |  66 lines

  1. Zprofiler :  a tool for optimizing Delphi programs on Pentium computers. version 1.10
  2. -------------------------------------------------------------------------------------
  3. This utility component enables the assessment of execution times of code fragments with a 0.01 microsecond
  4. resolution. It is based on the cpu clock of Pentium computers.
  5.  
  6. Running the demo
  7. The demo does not require installation of the component ! In de Delphi IDE : open demo.dpr and run it.
  8.  
  9. Installing the component :
  10. Put the files z_prof.pas , z_prof.dfm and z_prof.dcr in one of your library directories, and install z_prof as usual.
  11. The component Zprofiler will appear on the samples page of the palette.
  12.  
  13. Usage :
  14. Using the component is extremely simple. Drop zprofiler on your form, and a modeless window will appear
  15. with a grid containing the timing results (during runtime). 
  16. There is only one method you need to use for marking enclosed timing blocks :
  17. profile.mark(nr:integer; aactive:boolean); 
  18.              nr : number of the code fragment , currently maximal 20 blocks
  19.              aactive : start/ stop marking a code fragment
  20. (NB prefereably, use the global profile pointer instead of zprofiler1 generated by Delphi)
  21. If you want to put markers in project units that have no form file, add the z_prof unit in its uses section,
  22. and instanciate the component dynamically if that has not yet been done elsewhere yet.
  23. The demo applies dynamic instantiation.  
  24.  
  25. Example :
  26.      profile.mark(1,true);      start timing fragment 1
  27.      <some code  >              the program code under investigation
  28.      profile.mark(1,false);     stop timing fragment 1
  29.  
  30. Running the demo
  31.  
  32.  
  33. Details :
  34. The markers act globally and are all owned by the mainform, accessible via the pointer "profile". Only one
  35. instance will be executed. Thus, there is no point to dropping more than one zprofiler on a form (no harm
  36. either). You can drop them on secondary forms as an easy way of updating the uses section with z_prof. 
  37. When you need more markers than the standard 20, increase the nmarks constant in z_prof.pas and recompile.
  38. The codemarkers act independently from each other.
  39. The component is already active in designmode from the moment it is "dropped" (the result grid remains
  40. hidden though). Thus you could time design operations as well. 
  41. If you prefer to instantiate the component dynamically, put z_prof in "uses" and make the call :
  42. tzprofiler.create(application.mainform);  {note that there is no reason for storing the resulting pointer}
  43.           
  44.  
  45. Technical information :
  46. The resolution of  0.01 microseconds is not completely realistic. The component corrects for its own overhead 
  47. as good as possible but I experience on my computer (133MHz Pentium) a reproducible residual 0.4 microseconds
  48. that I ascribe to the calling and return time of mark() method. Furthermore, there are occasional time lapses
  49. that are probably due to tasks in the operating system, or caused by cpu (cache) operations. 
  50. If you want to time a very short interval, the column that displays the fastest time is probably the most "clean".
  51. However, the mean execution time is a better estimator of practical purposes.
  52. NB it only works on Pentiums ! , don't forget to remove the component after developementphase is finished !
  53.  
  54. References
  55. Steve Durham,  C/C++ user journal  'A Testjig Tool for Pentium Optimization' (Dec 1996).
  56. Massimo , uPentium freeware component, downloaded from Delphi Super Page (June 1997)
  57.  
  58. History
  59. Changes from version 1.00 : an error in the overhead time correction for the "fastest" collumn has been fixed, 
  60. this text document has been updated and the demo was added.
  61.  
  62. Copyright
  63. Use it as you like. Feel free to adapt it to your needs, but if you publish it, please make proper references. 
  64. If you have suggestions or improvements,  send me an email :
  65. d950021@icpc00.icpc.fukui-u.ac.jp
  66. Antonie Baars, July 3, 1997